home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / scm / slib / mitcomp.pat < prev    next >
Text File  |  1999-04-19  |  43KB  |  1,467 lines

  1. ;"mitcomp.pat", patch file of definitions for compiling SLIB with MitScheme.
  2. ;;; Copyright (C) 1993 Matthew McDonald.
  3. ;
  4. ;Permission to copy this software, to redistribute it, and to use it
  5. ;for any purpose is granted, subject to the following restrictions and
  6. ;understandings.
  7. ;
  8. ;1.  Any copy made of this software must include this copyright notice
  9. ;in full.
  10. ;
  11. ;2.  I have made no warrantee or representation that the operation of
  12. ;this software will be error-free, and I am under no obligation to
  13. ;provide any services, by way of maintenance, update, or otherwise.
  14. ;
  15. ;3.  In conjunction with products arising from the use of this
  16. ;material, there shall be no use of my name in any advertising,
  17. ;promotional, or sales literature without prior written consent in
  18. ;each case.
  19.  
  20. From: mafm@cs.uwa.edu.au (Matthew MCDONALD)
  21.  
  22.     Added declarations to files providing these:
  23. dynamic alist hash hash-table logical random random-inexact modular
  24. prime charplot common-list-functions format generic-write pprint-file
  25. pretty-print-to-string object->string string-case printf line-i/o
  26. synchk priority-queue process red-black-tree sort
  27.  
  28. (for-each cf
  29.  '("dynamic.scm" "alist.scm" "hash.scm" "hashtab.scm" "logical.scm"
  30.    "random.scm" "randinex.scm" "modular.scm" "prime.scm" "charplot.scm"
  31.    "comlist.scm" "format.scm" "genwrite.scm" "ppfile.scm" "pp2str.scm"
  32.    "obj2str.scm" "strcase.scm" "printf.scm" "lineio.scm" "synchk.scm"
  33.    "priorque.scm" "process.scm" "rbtree.scm" "sort.scm))
  34.  
  35. while in the SLIB directory will compile all of these.
  36.  
  37.     They all appear to still be working... They should be
  38. everything CScheme currently uses (except [1] below.)
  39.  
  40. NOTES:
  41.  
  42. [1] Not altered:
  43.     debug           Not worth optimising
  44.     test           "   "     "
  45.     fluid-let          compiler chokes over
  46.                 (lambda () . body)
  47.     scmacro           Fails when compiled, not immediately obvious why
  48.     synclo             " " "
  49.     r4rsyn           " " "
  50.     yasos              requires the macros
  51.     collect           "        "   "
  52.  
  53. [2] removed 'sort from list of MIT features. The library version is
  54. more complete (and needed for charplot.)
  55.  
  56. [3] Remember that mitscheme.init gets the .bin put in the wrong place
  57. by the compiler and thus doesn't get recognised by LOAD.
  58. ======================================================================
  59. diff -c slib/alist.scm nlib/alist.scm
  60. *** slib/alist.scm    Thu Jan 21 00:01:34 1993
  61. --- nlib/alist.scm    Tue Feb  9 00:21:07 1993
  62. ***************
  63. *** 44,50 ****
  64.   ;(define rem (alist-remover string-ci=?))
  65.   ;(set! alist (rem alist "fOO"))
  66.   
  67. ! (define (predicate->asso pred)
  68.     (cond ((eq? eq? pred) assq)
  69.       ((eq? = pred) assv)
  70.       ((eq? eqv? pred) assv)
  71. --- 44,53 ----
  72.   ;(define rem (alist-remover string-ci=?))
  73.   ;(set! alist (rem alist "fOO"))
  74.   
  75. ! ;;; Declarations for CScheme
  76. ! (declare (usual-integrations))
  77. ! (define-integrable (predicate->asso pred)
  78.     (cond ((eq? eq? pred) assq)
  79.       ((eq? = pred) assv)
  80.       ((eq? eqv? pred) assv)
  81. ***************
  82. *** 57,69 ****
  83.               ((pred key (caar al)) (car al))
  84.               (else (l (cdr al)))))))))
  85.   
  86. ! (define (alist-inquirer pred)
  87.     (let ((assofun (predicate->asso pred)))
  88.       (lambda (alist key)
  89.         (let ((pair (assofun key alist)))
  90.       (and pair (cdr pair))))))
  91.   
  92. ! (define (alist-associator pred)
  93.     (let ((assofun (predicate->asso pred)))
  94.       (lambda (alist key val)
  95.         (let* ((pair (assofun key alist)))
  96. --- 60,72 ----
  97.               ((pred key (caar al)) (car al))
  98.               (else (l (cdr al)))))))))
  99.   
  100. ! (define-integrable (alist-inquirer pred)
  101.     (let ((assofun (predicate->asso pred)))
  102.       (lambda (alist key)
  103.         (let ((pair (assofun key alist)))
  104.       (and pair (cdr pair))))))
  105.   
  106. ! (define-integrable (alist-associator pred)
  107.     (let ((assofun (predicate->asso pred)))
  108.       (lambda (alist key val)
  109.         (let* ((pair (assofun key alist)))
  110. ***************
  111. *** 71,77 ****
  112.               alist)
  113.             (else (cons (cons key val) alist)))))))
  114.   
  115. ! (define (alist-remover pred)
  116.     (lambda (alist key)
  117.       (cond ((null? alist) alist)
  118.         ((pred key (caar alist)) (cdr alist))
  119. --- 74,80 ----
  120.               alist)
  121.             (else (cons (cons key val) alist)))))))
  122.   
  123. ! (define-integrable (alist-remover pred)
  124.     (lambda (alist key)
  125.       (cond ((null? alist) alist)
  126.         ((pred key (caar alist)) (cdr alist))
  127. diff -c slib/charplot.scm nlib/charplot.scm
  128. *** slib/charplot.scm    Sat Nov 14 21:50:54 1992
  129. --- nlib/charplot.scm    Tue Feb  9 00:21:07 1993
  130. ***************
  131. *** 7,12 ****
  132. --- 7,24 ----
  133.   ;are strings with names to label the x and y axii with.
  134.   
  135.   ;;;;---------------------------------------------------------------
  136. + ;;; Declarations for CScheme
  137. + (declare (usual-integrations))
  138. + (declare (integrate-external "sort"))
  139. + (declare (integrate
  140. +       rows
  141. +       columns
  142. +       charplot:height
  143. +       charplot:width
  144. +       charplot:plot
  145. +       plot!))
  146.   (require 'sort)
  147.   
  148.   (define rows 24)
  149. ***************
  150. *** 27,39 ****
  151.        (write-char char)
  152.        (charplot:printn! (+ n -1) char))))
  153.   
  154. ! (define (charplot:center-print! str width)
  155.     (let ((lpad (quotient (- width (string-length str)) 2)))
  156.       (charplot:printn! lpad #\ )
  157.       (display str)
  158.       (charplot:printn! (- width (+ (string-length  str) lpad)) #\ )))
  159.   
  160. ! (define (scale-it z scale)
  161.     (if (and (exact? z) (integer? z))
  162.         (quotient (* z (car scale)) (cadr scale))
  163.         (inexact->exact (round (/ (* z (car scale)) (cadr scale))))))
  164. --- 39,51 ----
  165.        (write-char char)
  166.        (charplot:printn! (+ n -1) char))))
  167.   
  168. ! (define-integrable (charplot:center-print! str width)
  169.     (let ((lpad (quotient (- width (string-length str)) 2)))
  170.       (charplot:printn! lpad #\ )
  171.       (display str)
  172.       (charplot:printn! (- width (+ (string-length  str) lpad)) #\ )))
  173.   
  174. ! (define-integrable (scale-it z scale)
  175.     (if (and (exact? z) (integer? z))
  176.         (quotient (* z (car scale)) (cadr scale))
  177.         (inexact->exact (round (/ (* z (car scale)) (cadr scale))))))
  178. diff -c slib/comlist.scm nlib/comlist.scm
  179. *** slib/comlist.scm    Wed Jan 27 11:08:44 1993
  180. --- nlib/comlist.scm    Tue Feb  9 00:21:08 1993
  181. ***************
  182. *** 6,11 ****
  183. --- 6,14 ----
  184.   
  185.   ;;;; LIST FUNCTIONS FROM COMMON LISP
  186.   
  187. + ;;; Declarations for CScheme
  188. + (declare (usual-integrations))
  189.   ;;;From: hugh@ear.mit.edu (Hugh Secker-Walker)
  190.   (define (make-list k . init)
  191.     (set! init (if (pair? init) (car init)))
  192. ***************
  193. *** 13,21 ****
  194.          (result '() (cons init result)))
  195.         ((<= k 0) result)))
  196.   
  197. ! (define (copy-list lst) (append lst '()))
  198.   
  199. ! (define (adjoin e l) (if (memq e l) l (cons e l)))
  200.   
  201.   (define (union l1 l2)
  202.     (cond ((null? l1) l2)
  203. --- 16,24 ----
  204.          (result '() (cons init result)))
  205.         ((<= k 0) result)))
  206.   
  207. ! (define-integrable (copy-list lst) (append lst '()))
  208.   
  209. ! (define-integrable (adjoin e l) (if (memq e l) l (cons e l)))
  210.   
  211.   (define (union l1 l2)
  212.     (cond ((null? l1) l2)
  213. ***************
  214. *** 33,39 ****
  215.       ((memv (car l1) l2) (set-difference (cdr l1) l2))
  216.       (else (cons (car l1) (set-difference (cdr l1) l2)))))
  217.   
  218. ! (define (position obj lst)
  219.     (letrec ((pos (lambda (n lst)
  220.             (cond ((null? lst) #f)
  221.               ((eqv? obj (car lst)) n)
  222. --- 36,42 ----
  223.       ((memv (car l1) l2) (set-difference (cdr l1) l2))
  224.       (else (cons (car l1) (set-difference (cdr l1) l2)))))
  225.   
  226. ! (define-integrable (position obj lst)
  227.     (letrec ((pos (lambda (n lst)
  228.             (cond ((null? lst) #f)
  229.               ((eqv? obj (car lst)) n)
  230. ***************
  231. *** 45,51 ****
  232.         init
  233.         (reduce-init p (p init (car l)) (cdr l))))
  234.   
  235. ! (define (reduce p l)
  236.     (cond ((null? l) l)
  237.       ((null? (cdr l)) (car l))
  238.       (else (reduce-init p (car l) (cdr l)))))
  239. --- 48,54 ----
  240.         init
  241.         (reduce-init p (p init (car l)) (cdr l))))
  242.   
  243. ! (define-integrable (reduce p l)
  244.     (cond ((null? l) l)
  245.       ((null? (cdr l)) (car l))
  246.       (else (reduce-init p (car l) (cdr l)))))
  247. ***************
  248. *** 58,64 ****
  249.     (or (null? l)
  250.         (and (pred (car l)) (every pred (cdr l)))))
  251.   
  252. ! (define (notevery pred l) (not (every pred l)))
  253.   
  254.   (define (find-if t l)
  255.     (cond ((null? l) #f)
  256. --- 61,67 ----
  257.     (or (null? l)
  258.         (and (pred (car l)) (every pred (cdr l)))))
  259.   
  260. ! (define-integrable (notevery pred l) (not (every pred l)))
  261.   
  262.   (define (find-if t l)
  263.     (cond ((null? l) #f)
  264. ***************
  265. *** 121,141 ****
  266.   (define (nthcdr n lst)
  267.     (if (zero? n) lst (nthcdr (+ -1 n) (cdr lst))))
  268.   
  269. ! (define (last lst n)
  270.     (nthcdr (- (length lst) n) lst))
  271.   
  272.   ;;;; CONDITIONALS
  273.   
  274. ! (define (and? . args)
  275.     (cond ((null? args) #t)
  276.       ((car args) (apply and? (cdr args)))
  277.       (else #f)))
  278.   
  279. ! (define (or? . args)
  280.     (cond ((null? args) #f)
  281.       ((car args) #t)
  282.       (else (apply or? (cdr args)))))
  283.   
  284. ! (define (identity x) x)
  285.   
  286.   (require 'rev3-procedures)
  287. --- 124,144 ----
  288.   (define (nthcdr n lst)
  289.     (if (zero? n) lst (nthcdr (+ -1 n) (cdr lst))))
  290.   
  291. ! (define-integrable (last lst n)
  292.     (nthcdr (- (length lst) n) lst))
  293.   
  294.   ;;;; CONDITIONALS
  295.   
  296. ! (define-integrable (and? . args)
  297.     (cond ((null? args) #t)
  298.       ((car args) (apply and? (cdr args)))
  299.       (else #f)))
  300.   
  301. ! (define-integrable (or? . args)
  302.     (cond ((null? args) #f)
  303.       ((car args) #t)
  304.       (else (apply or? (cdr args)))))
  305.   
  306. ! (define-integrable (identity x) x)
  307.   
  308.   (require 'rev3-procedures)
  309. diff -c slib/dynamic.scm nlib/dynamic.scm
  310. *** slib/dynamic.scm    Thu Sep 17 23:35:46 1992
  311. --- nlib/dynamic.scm    Tue Feb  9 00:21:08 1993
  312. ***************
  313. *** 31,36 ****
  314. --- 31,43 ----
  315.   ;
  316.   ;There was also a DYNAMIC-BIND macro which I haven't implemented.
  317.   
  318. + ;;; Declarations for CScheme
  319. + (declare (usual-integrations))
  320. + (declare (integrate-external "record"))
  321. + (declare (integrate-external "dynwind"))
  322. + (declare (integrate dynamic:errmsg))
  323.   (require 'record)
  324.   (require 'dynamic-wind)
  325.   
  326. ***************
  327. *** 48,60 ****
  328.     (record-accessor dynamic-environment-rtd 'parent))
  329.   
  330.   (define *current-dynamic-environment* #f)
  331. ! (define (extend-current-dynamic-environment dynamic obj)
  332.     (set! *current-dynamic-environment*
  333.       (make-dynamic-environment dynamic obj
  334.                     *current-dynamic-environment*)))
  335.   
  336.   (define dynamic-rtd (make-record-type "dynamic" '()))
  337. ! (define make-dynamic
  338.     (let ((dynamic-constructor (record-constructor dynamic-rtd)))
  339.       (lambda (obj)
  340.         (let ((dynamic (dynamic-constructor)))
  341. --- 55,69 ----
  342.     (record-accessor dynamic-environment-rtd 'parent))
  343.   
  344.   (define *current-dynamic-environment* #f)
  345. ! (define-integrable (extend-current-dynamic-environment dynamic obj)
  346.     (set! *current-dynamic-environment*
  347.       (make-dynamic-environment dynamic obj
  348.                     *current-dynamic-environment*)))
  349.   
  350.   (define dynamic-rtd (make-record-type "dynamic" '()))
  351. ! (define-integrable make-dynamic
  352.     (let ((dynamic-constructor (record-constructor dynamic-rtd)))
  353.       (lambda (obj)
  354.         (let ((dynamic (dynamic-constructor)))
  355. ***************
  356. *** 61,68 ****
  357.       (extend-current-dynamic-environment dynamic obj)
  358.       dynamic))))
  359.   
  360. ! (define dynamic? (record-predicate dynamic-rtd))
  361. ! (define (guarantee-dynamic dynamic)
  362.     (or (dynamic? dynamic)
  363.         (slib:error "Not a dynamic" dynamic)))
  364.   
  365. --- 70,78 ----
  366.       (extend-current-dynamic-environment dynamic obj)
  367.       dynamic))))
  368.   
  369. ! (define-integrable dynamic? (record-predicate dynamic-rtd))
  370. ! (define-integrable (guarantee-dynamic dynamic)
  371.     (or (dynamic? dynamic)
  372.         (slib:error "Not a dynamic" dynamic)))
  373.   
  374. ***************
  375. *** 69,75 ****
  376.   (define dynamic:errmsg
  377.     "No value defined for this dynamic in the current dynamic environment")
  378.   
  379. ! (define (dynamic-ref dynamic)
  380.     (guarantee-dynamic dynamic)
  381.     (let loop ((env *current-dynamic-environment*))
  382.       (cond ((not env)
  383. --- 79,85 ----
  384.   (define dynamic:errmsg
  385.     "No value defined for this dynamic in the current dynamic environment")
  386.   
  387. ! (define-integrable (dynamic-ref dynamic)
  388.     (guarantee-dynamic dynamic)
  389.     (let loop ((env *current-dynamic-environment*))
  390.       (cond ((not env)
  391. ***************
  392. *** 79,85 ****
  393.         (else
  394.          (loop (dynamic-environment:parent env))))))
  395.   
  396. ! (define (dynamic-set! dynamic obj)
  397.     (guarantee-dynamic dynamic)
  398.     (let loop ((env *current-dynamic-environment*))
  399.       (cond ((not env)
  400. --- 89,95 ----
  401.         (else
  402.          (loop (dynamic-environment:parent env))))))
  403.   
  404. ! (define-integrable (dynamic-set! dynamic obj)
  405.     (guarantee-dynamic dynamic)
  406.     (let loop ((env *current-dynamic-environment*))
  407.       (cond ((not env)
  408. diff -c slib/format.scm nlib/format.scm
  409. *** slib/format.scm    Tue Jan  5 14:56:48 1993
  410. --- nlib/format.scm    Tue Feb  9 00:21:09 1993
  411. ***************
  412. *** 78,84 ****
  413.   ;   * removed C-style padding support
  414.   ;
  415.   
  416. ! ;;; SCHEME IMPLEMENTATION DEPENDENCIES ---------------------------------------
  417.   
  418.   ;; To configure the format module for your scheme system, set the variable
  419.   ;; format:scheme-system to one of the symbols of (slib elk any). You may add
  420. --- 78,88 ----
  421.   ;   * removed C-style padding support
  422.   ;
  423.   
  424. ! ;;; SCHEME IMPLEMENTATION DEPENDENCIES
  425. ! ;;; ---------------------------------------
  426. ! ;;; (minimal) Declarations for CScheme
  427. ! (declare (usual-integrations))
  428.   
  429.   ;; To configure the format module for your scheme system, set the variable
  430.   ;; format:scheme-system to one of the symbols of (slib elk any). You may add
  431. diff -c slib/genwrite.scm nlib/genwrite.scm
  432. *** slib/genwrite.scm    Mon Oct 19 14:49:06 1992
  433. --- nlib/genwrite.scm    Tue Feb  9 00:21:10 1993
  434. ***************
  435. *** 26,31 ****
  436. --- 26,34 ----
  437.   ;
  438.   ; where display-string = (lambda (s) (for-each write-char (string->list s)) #t)
  439.   
  440. + ;;; (minimal) Declarations for CScheme
  441. + (declare (usual-integrations))
  442.   (define (generic-write obj display? width output)
  443.   
  444.     (define (read-macro? l)
  445. diff -c slib/hash.scm nlib/hash.scm
  446. *** slib/hash.scm    Thu Sep 10 00:05:52 1992
  447. --- nlib/hash.scm    Tue Feb  9 00:21:10 1993
  448. ***************
  449. *** 23,35 ****
  450.   ;the equality predicate pred.  Pred should be EQ?, EQV?, EQUAL?, =,
  451.   ;CHAR=?, CHAR-CI=?, STRING=?, or STRING-CI=?.
  452.    
  453. ! (define (hash:hash-char char n)
  454.     (modulo (char->integer char) n))
  455.   
  456. ! (define (hash:hash-char-ci char n)
  457.     (modulo (char->integer (char-downcase char)) n))
  458.   
  459. ! (define (hash:hash-symbol sym n)
  460.     (hash:hash-string (symbol->string sym) n))
  461.   
  462.   ;;; I am trying to be careful about overflow and underflow here.
  463. --- 23,40 ----
  464.   ;the equality predicate pred.  Pred should be EQ?, EQV?, EQUAL?, =,
  465.   ;CHAR=?, CHAR-CI=?, STRING=?, or STRING-CI=?.
  466.    
  467. ! ;;; Declarations for CScheme
  468. ! (declare (usual-integrations))
  469. ! (declare (integrate hash))
  470. ! (define-integrable (hash:hash-char char n)
  471.     (modulo (char->integer char) n))
  472.   
  473. ! (define-integrable (hash:hash-char-ci char n)
  474.     (modulo (char->integer (char-downcase char)) n))
  475.   
  476. ! (define-integrable (hash:hash-symbol sym n)
  477.     (hash:hash-string (symbol->string sym) n))
  478.   
  479.   ;;; I am trying to be careful about overflow and underflow here.
  480. ***************
  481. *** 173,179 ****
  482.   
  483.   (define hashq hashv)
  484.   
  485. ! (define (predicate->hash pred)
  486.     (cond ((eq? pred eq?) hashq)
  487.       ((eq? pred eqv?) hashv)
  488.       ((eq? pred equal?) hash)
  489. --- 178,184 ----
  490.   
  491.   (define hashq hashv)
  492.   
  493. ! (define-integrable (predicate->hash pred)
  494.     (cond ((eq? pred eq?) hashq)
  495.       ((eq? pred eqv?) hashv)
  496.       ((eq? pred equal?) hash)
  497. diff -c slib/hashtab.scm nlib/hashtab.scm
  498. *** slib/hashtab.scm    Mon Oct 19 14:49:44 1992
  499. --- nlib/hashtab.scm    Tue Feb  9 00:21:11 1993
  500. ***************
  501. *** 36,47 ****
  502.   ;Returns a procedure of 2 arguments, hashtab and key, which modifies
  503.   ;hashtab so that the association whose key is key removed.
  504.   
  505.   (require 'hash)
  506.   (require 'alist)
  507.   
  508. ! (define (make-hash-table k) (make-vector k '()))
  509.   
  510. ! (define (predicate->hash-asso pred)
  511.     (let ((hashfun (predicate->hash pred))
  512.       (asso (predicate->asso pred)))
  513.       (lambda (key hashtab)
  514. --- 36,53 ----
  515.   ;Returns a procedure of 2 arguments, hashtab and key, which modifies
  516.   ;hashtab so that the association whose key is key removed.
  517.   
  518. + ;;; Declarations for CScheme
  519. + (declare (usual-integrations))
  520. + (declare (integrate-external "hash"))
  521. + (declare (integrate-external "alist"))
  522.   (require 'hash)
  523.   (require 'alist)
  524.   
  525. ! (define-integrable (make-hash-table k) (make-vector k '()))
  526.   
  527. ! (define-integrable (predicate->hash-asso pred)
  528.     (let ((hashfun (predicate->hash pred))
  529.       (asso (predicate->asso pred)))
  530.       (lambda (key hashtab)
  531. ***************
  532. *** 48,54 ****
  533.         (asso key
  534.           (vector-ref hashtab (hashfun key (vector-length hashtab)))))))
  535.   
  536. ! (define (hash-inquirer pred)
  537.     (let ((hashfun (predicate->hash pred))
  538.       (ainq (alist-inquirer pred)))
  539.       (lambda (hashtab key)
  540. --- 54,60 ----
  541.         (asso key
  542.           (vector-ref hashtab (hashfun key (vector-length hashtab)))))))
  543.   
  544. ! (define-integrable (hash-inquirer pred)
  545.     (let ((hashfun (predicate->hash pred))
  546.       (ainq (alist-inquirer pred)))
  547.       (lambda (hashtab key)
  548. ***************
  549. *** 55,61 ****
  550.         (ainq (vector-ref hashtab (hashfun key (vector-length hashtab)))
  551.           key))))
  552.   
  553. ! (define (hash-associator pred)
  554.     (let ((hashfun (predicate->hash pred))
  555.       (asso (alist-associator pred)))
  556.       (lambda (hashtab key val)
  557. --- 61,67 ----
  558.         (ainq (vector-ref hashtab (hashfun key (vector-length hashtab)))
  559.           key))))
  560.   
  561. ! (define-integrable (hash-associator pred)
  562.     (let ((hashfun (predicate->hash pred))
  563.       (asso (alist-associator pred)))
  564.       (lambda (hashtab key val)
  565. ***************
  566. *** 64,70 ****
  567.                (asso (vector-ref hashtab num) key val)))
  568.         hashtab)))
  569.   
  570. ! (define (hash-remover pred)
  571.     (let ((hashfun (predicate->hash pred))
  572.       (arem (alist-remover pred)))
  573.       (lambda (hashtab key)
  574. --- 70,76 ----
  575.                (asso (vector-ref hashtab num) key val)))
  576.         hashtab)))
  577.   
  578. ! (define-integrable (hash-remover pred)
  579.     (let ((hashfun (predicate->hash pred))
  580.       (arem (alist-remover pred)))
  581.       (lambda (hashtab key)
  582. diff -c slib/lineio.scm nlib/lineio.scm
  583. *** slib/lineio.scm    Sun Oct 25 01:40:38 1992
  584. --- nlib/lineio.scm    Tue Feb  9 00:21:11 1993
  585. ***************
  586. *** 28,33 ****
  587. --- 28,36 ----
  588.   ;unspecified value.  Port may be ommited, in which case it defaults to
  589.   ;the value returned by current-input-port.
  590.   
  591. + ;;; Declarations for CScheme
  592. + (declare (usual-integrations))
  593.   (define (read-line . arg)
  594.     (let* ((char (apply read-char arg)))
  595.       (if (eof-object? char)
  596. ***************
  597. *** 56,61 ****
  598.               (+ 1 i) #f))))
  599.         (string-set! str i char)))))
  600.   
  601. ! (define (write-line str . arg)
  602.     (apply display str arg)
  603.     (apply newline arg))
  604. --- 59,64 ----
  605.               (+ 1 i) #f))))
  606.         (string-set! str i char)))))
  607.   
  608. ! (define-integrable (write-line str . arg)
  609.     (apply display str arg)
  610.     (apply newline arg))
  611. diff -c slib/logical.scm nlib/logical.scm
  612. *** slib/logical.scm    Mon Feb  1 22:22:04 1993
  613. --- nlib/logical.scm    Tue Feb  9 00:21:11 1993
  614. ***************
  615. *** 48,53 ****
  616. --- 48,66 ----
  617.   ;
  618.   ;;;;------------------------------------------------------------------
  619.   
  620. + ;;; Declarations for CScheme
  621. + (declare (usual-integrations))
  622. + (declare (integrate logand        ; Exported functions
  623. +             logor
  624. +             logxor
  625. +             lognot
  626. +             ash
  627. +             logcount
  628. +             integer-length
  629. +             bit-extract
  630. +             ipow-by-squaring
  631. +             integer-expt))
  632.   (define logical:integer-expt
  633.     (if (provided? 'inexact)
  634.         expt
  635. ***************
  636. *** 61,67 ****
  637.                       (quotient k 2)
  638.                       (if (even? k) acc (proc acc x))
  639.                       proc))))
  640.   (define (logical:logand n1 n2)
  641.     (cond ((= n1 n2) n1)
  642.       ((zero? n1) 0)
  643. --- 74,79 ----
  644. ***************
  645. *** 90,102 ****
  646.           (vector-ref (vector-ref logical:boole-xor (modulo n1 16))
  647.               (modulo n2 16))))))
  648.   
  649. ! (define (logical:lognot n) (- -1 n))
  650.   
  651. ! (define (logical:bit-extract n start end)
  652.     (logical:logand (- (logical:integer-expt 2 (- end start)) 1)
  653.             (logical:ash n (- start))))
  654.   
  655. ! (define (logical:ash int cnt)
  656.     (if (negative? cnt)
  657.         (let ((n (logical:integer-expt 2 (- cnt))))
  658.       (if (negative? int)
  659. --- 102,114 ----
  660.           (vector-ref (vector-ref logical:boole-xor (modulo n1 16))
  661.               (modulo n2 16))))))
  662.   
  663. ! (define-integrable (logical:lognot n) (- -1 n))
  664.   
  665. ! (define-integrable (logical:bit-extract n start end)
  666.     (logical:logand (- (logical:integer-expt 2 (- end start)) 1)
  667.             (logical:ash n (- start))))
  668.   
  669. ! (define-integrable (logical:ash int cnt)
  670.     (if (negative? cnt)
  671.         (let ((n (logical:integer-expt 2 (- cnt))))
  672.       (if (negative? int)
  673. ***************
  674. *** 104,110 ****
  675.           (quotient int n)))
  676.         (* (logical:integer-expt 2 cnt) int)))
  677.   
  678. ! (define (logical:ash-4 x)
  679.     (if (negative? x)
  680.         (+ -1 (quotient (+ 1 x) 16))
  681.         (quotient x 16)))
  682. --- 116,122 ----
  683.           (quotient int n)))
  684.         (* (logical:integer-expt 2 cnt) int)))
  685.   
  686. ! (define-integrable (logical:ash-4 x)
  687.     (if (negative? x)
  688.         (+ -1 (quotient (+ 1 x) 16))
  689.         (quotient x 16)))
  690. diff -c slib/mitscheme.init nlib/mitscheme.init
  691. *** slib/mitscheme.init    Fri Jan 22 00:52:04 1993
  692. --- nlib/mitscheme.init    Tue Feb  9 00:21:12 1993
  693. ***************
  694. *** 48,55 ****
  695.   
  696.   ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  697.   ;;; use this definition if your system doesn't have such a procedure.
  698. ! ;(define (force-output . arg) #t)
  699. ! (define force-output flush-output)
  700.   
  701.   ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  702.   ;;; be returned by CHAR->INTEGER.  It is defined by MITScheme.
  703. --- 47,54 ----
  704.   
  705.   ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  706.   ;;; use this definition if your system doesn't have such a procedure.
  707. ! (define (force-output . arg) #t)
  708. ! ;(define force-output flush-output)
  709.   
  710.   ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  711.   ;;; be returned by CHAR->INTEGER.  It is defined by MITScheme.
  712. diff -c slib/modular.scm nlib/modular.scm
  713. *** slib/modular.scm    Sun Feb  2 12:53:26 1992
  714. --- nlib/modular.scm    Tue Feb  9 00:21:13 1993
  715. ***************
  716. *** 36,41 ****
  717. --- 36,48 ----
  718.   ;Returns (k2 ^ k3) mod k1.
  719.   ;
  720.   ;;;;--------------------------------------------------------------
  721. + ;;; Declarations for CScheme
  722. + (declare (usual-integrations))
  723. + (declare (integrate-external "logical"))
  724. + (declare (integrate modular:negate  extended-euclid))
  725.   (require 'logical)
  726.   
  727.   ;;; from:
  728. ***************
  729. *** 51,57 ****
  730.             (caddr res)
  731.             (- (cadr res) (* (quotient a b) (caddr res)))))))
  732.   
  733. ! (define (modular:invert m a)
  734.     (let ((d (modular:extended-euclid a m)))
  735.       (if (= 1 (car d))
  736.       (modulo (cadr d) m)
  737. --- 58,64 ----
  738.             (caddr res)
  739.             (- (cadr res) (* (quotient a b) (caddr res)))))))
  740.   
  741. ! (define-integrable (modular:invert m a)
  742.     (let ((d (modular:extended-euclid a m)))
  743.       (if (= 1 (car d))
  744.       (modulo (cadr d) m)
  745. ***************
  746. *** 59,67 ****
  747.   
  748.   (define modular:negate -)
  749.   
  750. ! (define (modular:+ m a b) (modulo (+ (- a m) b) m))
  751.   
  752. ! (define (modular:- m a b) (modulo (- a b) m))
  753.   
  754.   ;;; See: L'Ecuyer, P. and Cote, S. "Implementing a Random Number Package
  755.   ;;; with Splitting Facilities." ACM Transactions on Mathematical
  756. --- 66,74 ----
  757.   
  758.   (define modular:negate -)
  759.   
  760. ! (define-integrable (modular:+ m a b) (modulo (+ (- a m) b) m))
  761.   
  762. ! (define-integrable (modular:- m a b) (modulo (- a b) m))
  763.   
  764.   ;;; See: L'Ecuyer, P. and Cote, S. "Implementing a Random Number Package
  765.   ;;; with Splitting Facilities." ACM Transactions on Mathematical
  766. ***************
  767. *** 98,104 ****
  768.         (modulo (+ (if (positive? p) (- p m) p)
  769.                (* a0 (modulo b q))) m)))))
  770.   
  771. ! (define (modular:expt m a b)
  772.     (cond ((= a 1) 1)
  773.       ((= a (- m 1)) (if (odd? b) a 1))
  774.       ((zero? a) 0)
  775. --- 105,111 ----
  776.         (modulo (+ (if (positive? p) (- p m) p)
  777.                (* a0 (modulo b q))) m)))))
  778.   
  779. ! (define-integrable (modular:expt m a b)
  780.     (cond ((= a 1) 1)
  781.       ((= a (- m 1)) (if (odd? b) a 1))
  782.       ((zero? a) 0)
  783. diff -c slib/obj2str.scm nlib/obj2str.scm
  784. *** slib/obj2str.scm    Mon Oct 19 14:49:08 1992
  785. --- nlib/obj2str.scm    Tue Feb  9 00:21:13 1993
  786. ***************
  787. *** 2,13 ****
  788.   
  789.   (require 'generic-write)
  790.   
  791.   ; (object->string obj) returns the textual representation of 'obj' as a
  792.   ; string.
  793.   ;
  794.   ; Note: (write obj) = (display (object->string obj))
  795.   
  796. ! (define (object->string obj)
  797.     (let ((result '()))
  798.       (generic-write obj #f #f (lambda (str) (set! result (cons str result)) #t))
  799.       (reverse-string-append result)))
  800. --- 2,17 ----
  801.   
  802.   (require 'generic-write)
  803.   
  804. + ;;; Declarations for CScheme
  805. + (declare (usual-integrations))
  806. + (declare (integrate-external "genwrite"))
  807.   ; (object->string obj) returns the textual representation of 'obj' as a
  808.   ; string.
  809.   ;
  810.   ; Note: (write obj) = (display (object->string obj))
  811.   
  812. ! (define-integrable (object->string obj)
  813.     (let ((result '()))
  814.       (generic-write obj #f #f (lambda (str) (set! result (cons str result)) #t))
  815.       (reverse-string-append result)))
  816. diff -c slib/pp2str.scm nlib/pp2str.scm
  817. *** slib/pp2str.scm    Mon Oct 19 14:49:08 1992
  818. --- nlib/pp2str.scm    Tue Feb  9 00:21:13 1993
  819. ***************
  820. *** 2,11 ****
  821.   
  822.   (require 'generic-write)
  823.   
  824.   ; (pretty-print-to-string obj) returns a string with the pretty-printed
  825.   ; textual representation of 'obj'.
  826.   
  827. ! (define (pp:pretty-print-to-string obj)
  828.     (let ((result '()))
  829.       (generic-write obj #f 79 (lambda (str) (set! result (cons str result)) #t))
  830.       (reverse-string-append result)))
  831. --- 2,16 ----
  832.   
  833.   (require 'generic-write)
  834.   
  835. + ;;; Declarations for CScheme
  836. + (declare (usual-integrations))
  837. + (declare (integrate-external "genwrite"))
  838. + (declare (integrate pretty-print-to-string))
  839.   ; (pretty-print-to-string obj) returns a string with the pretty-printed
  840.   ; textual representation of 'obj'.
  841.   
  842. ! (define-integrable (pp:pretty-print-to-string obj)
  843.     (let ((result '()))
  844.       (generic-write obj #f 79 (lambda (str) (set! result (cons str result)) #t))
  845.       (reverse-string-append result)))
  846. diff -c slib/ppfile.scm nlib/ppfile.scm
  847. *** slib/ppfile.scm    Mon Oct 19 14:49:08 1992
  848. --- nlib/ppfile.scm    Tue Feb  9 00:21:14 1993
  849. ***************
  850. *** 10,15 ****
  851. --- 10,19 ----
  852.   ;
  853.   (require 'pretty-print)
  854.   
  855. + ;;; Declarations for CScheme
  856. + (declare (usual-integrations))
  857. + (declare (integrate-external "pp"))
  858.   (define (pprint-file ifile . optarg)
  859.     (let ((lst (call-with-input-file ifile
  860.              (lambda (iport)
  861. diff -c slib/prime.scm nlib/prime.scm
  862. *** slib/prime.scm    Mon Feb  8 20:49:46 1993
  863. --- nlib/prime.scm    Tue Feb  9 00:24:16 1993
  864. ***************
  865. *** 24,29 ****
  866. --- 24,39 ----
  867.   ;(sort! (factor k) <)
  868.   
  869.   ;;;;--------------------------------------------------------------
  870. + ;;; Declarations for CScheme
  871. + (declare (usual-integrations))
  872. + (declare (integrate-external "random"))
  873. + (declare (integrate-external "modular"))
  874. + (declare (integrate
  875. +       jacobi-symbol 
  876. +       prime?
  877. +       factor))
  878.   (require 'random)
  879.   (require 'modular)
  880.   
  881. ***************
  882. *** 56,62 ****
  883.   ;;;     choosing prime:trials=30 should be enough
  884.   (define prime:trials 30)
  885.   ;;; prime:product is a product of small primes.
  886. ! (define prime:product
  887.     (let ((p 210))
  888.       (for-each (lambda (s) (set! p (or (string->number s) p)))
  889.         '("2310" "30030" "510510" "9699690" "223092870"
  890. --- 66,72 ----
  891.   ;;;     choosing prime:trials=30 should be enough
  892.   (define prime:trials 30)
  893.   ;;; prime:product is a product of small primes.
  894. ! (define-integrable prime:product
  895.     (let ((p 210))
  896.       (for-each (lambda (s) (set! p (or (string->number s) p)))
  897.         '("2310" "30030" "510510" "9699690" "223092870"
  898. ***************
  899. *** 86,92 ****
  900.   ;                  |  f(u,v,2b,n/2) or f(u+b,v+b,2b,(n-u-v-b)/2) if n even
  901.   
  902.   ;Thm: f(1,1,2,(m-1)/2) = (p,q) iff pq=m for odd m.
  903. !  
  904.   ;It may be illuminating to consider the relation of the Lankinen function in
  905.   ;a `computational hierarchy' of other factoring functions.*  Assumptions are
  906.   ;made herein on the basis of conventional digital (binary) computers.  Also,
  907. --- 96,102 ----
  908.   ;                  |  f(u,v,2b,n/2) or f(u+b,v+b,2b,(n-u-v-b)/2) if n even
  909.   
  910.   ;Thm: f(1,1,2,(m-1)/2) = (p,q) iff pq=m for odd m.
  911.   ;It may be illuminating to consider the relation of the Lankinen function in
  912.   ;a `computational hierarchy' of other factoring functions.*  Assumptions are
  913.   ;made herein on the basis of conventional digital (binary) computers.  Also,
  914. ***************
  915. *** 94,100 ****
  916.   ;be factored is prime).  However, all algorithms would probably perform to
  917.   ;the same constant multiple of the given orders for complete composite
  918.   ;factorizations.
  919. !  
  920.   ;Thm: Eratosthenes' Sieve is very roughtly O(ln(n)/n) in time and
  921.   ;     O(n*log2(n)) in space.
  922.   ;Pf: It works with all prime factors less than n (about ln(n)/n by the prime
  923. --- 104,110 ----
  924.   ;be factored is prime).  However, all algorithms would probably perform to
  925.   ;the same constant multiple of the given orders for complete composite
  926.   ;factorizations.
  927.   ;Thm: Eratosthenes' Sieve is very roughtly O(ln(n)/n) in time and
  928.   ;     O(n*log2(n)) in space.
  929.   ;Pf: It works with all prime factors less than n (about ln(n)/n by the prime
  930. diff -c slib/priorque.scm nlib/priorque.scm
  931. *** slib/priorque.scm    Mon Oct 19 14:49:42 1992
  932. --- nlib/priorque.scm    Tue Feb  9 00:21:15 1993
  933. ***************
  934. *** 22,41 ****
  935.   ;;; 1989 MIT Press.
  936.   
  937.   (require 'record)
  938.   (define heap-rtd (make-record-type "heap" '(array size heap<?)))
  939. ! (define make-heap
  940.     (let ((cstr (record-constructor heap-rtd)))
  941.       (lambda (pred<?)
  942.         (cstr (make-vector 4) 0 pred<?))))
  943. ! (define heap-ref
  944.     (let ((ra (record-accessor heap-rtd 'array)))
  945.       (lambda (a i)
  946.         (vector-ref (ra a) (+ -1 i)))))
  947. ! (define heap-set!
  948.     (let ((ra (record-accessor heap-rtd 'array)))
  949.       (lambda (a i v)
  950.         (vector-set! (ra a) (+ -1 i) v))))
  951. ! (define heap-exchange
  952.     (let ((aa (record-accessor heap-rtd 'array)))
  953.       (lambda (a i j)
  954.         (set! i (+ -1 i))
  955. --- 22,53 ----
  956.   ;;; 1989 MIT Press.
  957.   
  958.   (require 'record)
  959. + ;;; Declarations for CScheme
  960. + (declare (usual-integrations))
  961. + (declare (integrate
  962. +       heap-size
  963. +       heap<?))
  964.   (define heap-rtd (make-record-type "heap" '(array size heap<?)))
  965. ! (define-integrable make-heap
  966.     (let ((cstr (record-constructor heap-rtd)))
  967.       (lambda (pred<?)
  968.         (cstr (make-vector 4) 0 pred<?))))
  969. ! (define-integrable heap-ref
  970.     (let ((ra (record-accessor heap-rtd 'array)))
  971.       (lambda (a i)
  972.         (vector-ref (ra a) (+ -1 i)))))
  973. ! (define-integrable heap-set!
  974.     (let ((ra (record-accessor heap-rtd 'array)))
  975.       (lambda (a i v)
  976.         (vector-set! (ra a) (+ -1 i) v))))
  977. ! (define-integrable heap-exchange
  978.     (let ((aa (record-accessor heap-rtd 'array)))
  979.       (lambda (a i j)
  980.         (set! i (+ -1 i))
  981. ***************
  982. *** 44,51 ****
  983. --- 56,66 ----
  984.            (tmp (vector-ref ra i)))
  985.       (vector-set! ra i (vector-ref ra j))
  986.       (vector-set! ra j tmp)))))
  987.   (define heap-size (record-accessor heap-rtd 'size))
  988.   (define heap<? (record-accessor heap-rtd 'heap<?))
  989.   (define heap-set-size
  990.     (let ((aa (record-accessor heap-rtd 'array))
  991.       (am (record-modifier heap-rtd 'array))
  992. ***************
  993. *** 59,68 ****
  994.           (vector-set! nra i (vector-ref ra i)))))
  995.       (sm a s)))))
  996.   
  997. ! (define (heap-parent i) (quotient i 2))
  998. ! (define (heap-left i) (* 2 i))
  999. ! (define (heap-right i) (+ 1 (* 2 i)))
  1000.   
  1001.   (define (heapify a i)
  1002.     (define l (heap-left i))
  1003.     (define r (heap-right i))
  1004. --- 74,85 ----
  1005.           (vector-set! nra i (vector-ref ra i)))))
  1006.       (sm a s)))))
  1007.   
  1008. ! (define-integrable (heap-parent i) (quotient i 2))
  1009.   
  1010. + (define-integrable (heap-left i) (* 2 i))
  1011. + (define-integrable (heap-right i) (+ 1 (* 2 i)))
  1012.   (define (heapify a i)
  1013.     (define l (heap-left i))
  1014.     (define r (heap-right i))
  1015. ***************
  1016. *** 99,104 ****
  1017. --- 116,122 ----
  1018.       max))
  1019.   
  1020.   (define heap #f)
  1021.   (define (heap-test)
  1022.     (set! heap (make-heap char>?))
  1023.     (heap-insert! heap #\A)
  1024. diff -c slib/process.scm nlib/process.scm
  1025. *** slib/process.scm    Wed Nov  4 12:26:50 1992
  1026. --- nlib/process.scm    Tue Feb  9 00:21:15 1993
  1027. ***************
  1028. *** 21,30 ****
  1029.   ;
  1030.   ;;;;----------------------------------------------------------------------
  1031.   
  1032.   (require 'full-continuation)
  1033.   (require 'queue)
  1034.   
  1035. ! (define (add-process! thunk1)
  1036.     (cond ((procedure? thunk1)
  1037.        (defer-ints)
  1038.        (enqueue! process:queue thunk1)
  1039. --- 21,33 ----
  1040.   ;
  1041.   ;;;;----------------------------------------------------------------------
  1042.   
  1043. + ;;; Declarations for CScheme
  1044. + (declare (usual-integrations))
  1045.   (require 'full-continuation)
  1046.   (require 'queue)
  1047.   
  1048. ! (define-integrable (add-process! thunk1)
  1049.     (cond ((procedure? thunk1)
  1050.        (defer-ints)
  1051.        (enqueue! process:queue thunk1)
  1052. ***************
  1053. *** 55,63 ****
  1054.   (define ints-disabled #f)
  1055.   (define alarm-deferred #f)
  1056.   
  1057. ! (define (defer-ints) (set! ints-disabled #t))
  1058.   
  1059. ! (define (allow-ints)
  1060.     (set! ints-disabled #f)
  1061.     (cond (alarm-deferred
  1062.         (set! alarm-deferred #f)
  1063. --- 58,66 ----
  1064.   (define ints-disabled #f)
  1065.   (define alarm-deferred #f)
  1066.   
  1067. ! (define-integrable (defer-ints) (set! ints-disabled #t))
  1068.   
  1069. ! (define-integrable (allow-ints)
  1070.     (set! ints-disabled #f)
  1071.     (cond (alarm-deferred
  1072.         (set! alarm-deferred #f)
  1073. ***************
  1074. *** 66,72 ****
  1075.   ;;; Make THE process queue.
  1076.   (define process:queue (make-queue))
  1077.   
  1078. ! (define (alarm-interrupt)
  1079.     (alarm 1)
  1080.     (if ints-disabled (set! alarm-deferred #t)
  1081.         (process:schedule!)))
  1082. --- 69,75 ----
  1083.   ;;; Make THE process queue.
  1084.   (define process:queue (make-queue))
  1085.   
  1086. ! (define-integrable (alarm-interrupt)
  1087.     (alarm 1)
  1088.     (if ints-disabled (set! alarm-deferred #t)
  1089.         (process:schedule!)))
  1090. diff -c slib/randinex.scm nlib/randinex.scm
  1091. *** slib/randinex.scm    Wed Nov 18 22:59:20 1992
  1092. --- nlib/randinex.scm    Tue Feb  9 00:21:16 1993
  1093. ***************
  1094. *** 47,52 ****
  1095. --- 47,59 ----
  1096.   ;For an exponential distribution with mean U use (* U (random:exp)).
  1097.   ;;;;-----------------------------------------------------------------
  1098.   
  1099. + ;;; Declarations for CScheme
  1100. + (declare (usual-integrations))
  1101. + (declare (integrate-external "random"))
  1102. + (declare (integrate
  1103. +       random:float-radix))
  1104.   (define random:float-radix
  1105.     (+ 1 (exact->inexact random:MASK)))
  1106.   
  1107. ***************
  1108. *** 56,61 ****
  1109. --- 63,69 ----
  1110.     (if (= 1.0 (+ 1 x))
  1111.         l
  1112.         (random:size-float (+ l 1) (/ x random:float-radix))))
  1113.   (define random:chunks/float (random:size-float 1 1.0))
  1114.   
  1115.   (define (random:uniform-chunk n state)
  1116. ***************
  1117. *** 67,73 ****
  1118.        random:float-radix)))
  1119.   
  1120.   ;;; Generate an inexact real between 0 and 1.
  1121. ! (define (random:uniform state)
  1122.     (random:uniform-chunk random:chunks/float state))
  1123.   
  1124.   ;;; If x and y are independent standard normal variables, then with
  1125. --- 75,81 ----
  1126.        random:float-radix)))
  1127.   
  1128.   ;;; Generate an inexact real between 0 and 1.
  1129. ! (define-integrable (random:uniform state)
  1130.     (random:uniform-chunk random:chunks/float state))
  1131.   
  1132.   ;;; If x and y are independent standard normal variables, then with
  1133. ***************
  1134. *** 89,95 ****
  1135.         (do! n (* r (cos t)))
  1136.         (if (positive? n) (do! (- n 1) (* r (sin t)))))))))
  1137.   
  1138. ! (define random:normal
  1139.     (let ((vect (make-vector 1)))
  1140.       (lambda args 
  1141.         (apply random:normal-vector! vect args)
  1142. --- 97,103 ----
  1143.         (do! n (* r (cos t)))
  1144.         (if (positive? n) (do! (- n 1) (* r (sin t)))))))))
  1145.   
  1146. ! (define-integrable random:normal
  1147.     (let ((vect (make-vector 1)))
  1148.       (lambda args 
  1149.         (apply random:normal-vector! vect args)
  1150. ***************
  1151. *** 98,104 ****
  1152.   ;;; For the uniform distibution on the hollow sphere, pick a normal
  1153.   ;;; family and scale.
  1154.   
  1155. ! (define (random:hollow-sphere! vect . args)
  1156.     (let ((ms (sqrt (apply random:normal-vector! vect args))))
  1157.       (do ((n (- (vector-length vect) 1) (- n 1)))
  1158.       ((negative? n))
  1159. --- 106,112 ----
  1160.   ;;; For the uniform distibution on the hollow sphere, pick a normal
  1161.   ;;; family and scale.
  1162.   
  1163. ! (define-integrable (random:hollow-sphere! vect . args)
  1164.     (let ((ms (sqrt (apply random:normal-vector! vect args))))
  1165.       (do ((n (- (vector-length vect) 1) (- n 1)))
  1166.       ((negative? n))
  1167. ***************
  1168. *** 117,123 ****
  1169.       ((negative? n))
  1170.         (vector-set! vect n (* r (vector-ref vect n))))))
  1171.   
  1172. ! (define (random:exp . args)
  1173.     (let ((state (if (null? args) *random-state* (car args))))
  1174.       (- (log (random:uniform state)))))
  1175.   
  1176. --- 125,131 ----
  1177.       ((negative? n))
  1178.         (vector-set! vect n (* r (vector-ref vect n))))))
  1179.   
  1180. ! (define-integrable (random:exp . args)
  1181.     (let ((state (if (null? args) *random-state* (car args))))
  1182.       (- (log (random:uniform state)))))
  1183.   
  1184. diff -c slib/random.scm nlib/random.scm
  1185. *** slib/random.scm    Tue Feb  2 00:02:58 1993
  1186. --- nlib/random.scm    Tue Feb  9 00:21:18 1993
  1187. ***************
  1188. *** 35,40 ****
  1189. --- 35,50 ----
  1190.   ;procedures for generating inexact distributions.
  1191.   ;;;;------------------------------------------------------------------
  1192.   
  1193. + ;;; Declarations for CScheme
  1194. + (declare (usual-integrations))
  1195. + (declare (integrate-external "logical"))
  1196. + (declare (integrateb
  1197. +       random:tap-1
  1198. +       random:size
  1199. +       random:chunk-size
  1200. +       random:MASK
  1201. +       random))
  1202.   (require 'logical)
  1203.   
  1204.   (define random:tap 24)
  1205. ***************
  1206. *** 45,50 ****
  1207. --- 55,61 ----
  1208.     (if (and (exact? trial) (>= most-positive-fixnum trial))
  1209.         l
  1210.         (random:size-int (- l 1)))))
  1211.   (define random:chunk-size (* 4 (random:size-int 8)))
  1212.   
  1213.   (define random:MASK
  1214. ***************
  1215. *** 107,113 ****
  1216.   ;;;random:uniform is in randinex.scm.  It is needed only if inexact is
  1217.   ;;;supported.
  1218.   
  1219. ! (define (random:make-random-state . args)
  1220.     (let ((state (if (null? args) *random-state* (car args))))
  1221.       (list->vector (vector->list state))))
  1222.   
  1223. --- 118,124 ----
  1224.   ;;;random:uniform is in randinex.scm.  It is needed only if inexact is
  1225.   ;;;supported.
  1226.   
  1227. ! (define-integrable (random:make-random-state . args)
  1228.     (let ((state (if (null? args) *random-state* (car args))))
  1229.       (list->vector (vector->list state))))
  1230.   
  1231. diff -c slib/rbtree.scm nlib/rbtree.scm
  1232. *** slib/rbtree.scm    Sat Jan  9 13:40:56 1993
  1233. --- nlib/rbtree.scm    Tue Feb  9 00:21:18 1993
  1234. ***************
  1235. *** 5,11 ****
  1236. --- 5,24 ----
  1237.   ;;;; PGS, 6 Jul 1990
  1238.   ;;; jaffer@ai.mit.edu Ported to SLIB, 1/6/93
  1239.   
  1240. + ;;; Declarations for CScheme
  1241. + (declare (usual-integrations))
  1242. + (declare (integrate 
  1243. +       rb-tree-root
  1244. +       set-rb-tree-root!
  1245. +       rb-tree-left-rotation-field-maintainer
  1246. +       rb-tree-right-rotation-field-maintainer
  1247. +       rb-tree-insertion-field-maintainer
  1248. +       rb-tree-deletion-field-maintainer
  1249. +       rb-tree-prior?))
  1250.   (require 'record)
  1251.   (define rb-tree
  1252.     (make-record-type
  1253.      "rb-tree"
  1254. ***************
  1255. *** 227,233 ****
  1256.          y)
  1257.       (set! x y)
  1258.       (set! y (rb-node-parent y)))))
  1259.   
  1260.   ;;;; Deletion.  We do not entirely follow Cormen, Leiserson and Rivest's lead
  1261.   ;;;; here, because their use of sentinels is in rather obscenely poor taste.
  1262. --- 240,245 ----
  1263. diff -c slib/sort.scm nlib/sort.scm
  1264. *** slib/sort.scm    Wed Nov  6 00:50:38 1991
  1265. --- nlib/sort.scm    Tue Feb  9 00:22:03 1993
  1266. ***************
  1267. *** 118,123 ****
  1268. --- 118,125 ----
  1269.   ;   in Scheme.
  1270.   ;;; --------------------------------------------------------------------
  1271.   
  1272. + ;;; Declarations for CScheme
  1273. + (declare (usual-integrations))        ; Honestly, nothing defined here clashes!
  1274.   
  1275.   ;;; (sorted? sequence less?)
  1276.   ;;; is true when sequence is a list (x0 x1 ... xm) or a vector #(x0 ... xm)
  1277. diff -c slib/printf.scm nlib/printf.scm
  1278. *** slib/printf.scm    Mon Oct 19 14:48:58 1992
  1279. --- nlib/printf.scm    Tue Feb  9 00:22:03 1993
  1280. ***************
  1281. *** 3,8 ****
  1282. --- 3,19 ----
  1283.   
  1284.   ;;; Floating point is not handled yet.  It should not be hard to do.
  1285.   
  1286. + ;;; Declarations for CScheme
  1287. + (declare (usual-integrations))
  1288. + (declare (integrate 
  1289. +       printf
  1290. +       fprintf
  1291. +       sprintf
  1292. +       stdin
  1293. +       stdout
  1294. +       stderr))
  1295.   (define (stdio:iprintf out format . args)
  1296.     (let loop ((pos 0) (args args))
  1297.       (if (< pos (string-length format))
  1298. ***************
  1299. *** 96,105 ****
  1300.         (else (out (string-ref format pos))
  1301.           (loop (+ pos 1) args))))))
  1302.   
  1303. ! (define (stdio:printf format . args)
  1304.     (apply stdio:iprintf display format args))
  1305.   
  1306. ! (define (stdio:fprintf port format . args)
  1307.     (if (equal? port (current-output-port))
  1308.         (apply stdio:iprintf display format args)
  1309.         (apply stdio:iprintf (lambda (x) (display x port)) format args)))
  1310. --- 107,116 ----
  1311.         (else (out (string-ref format pos))
  1312.           (loop (+ pos 1) args))))))
  1313.   
  1314. ! (define-integrable (stdio:printf format . args)
  1315.     (apply stdio:iprintf display format args))
  1316.   
  1317. ! (define-integrable (stdio:fprintf port format . args)
  1318.     (if (equal? port (current-output-port))
  1319.         (apply stdio:iprintf display format args)
  1320.         (apply stdio:iprintf (lambda (x) (display x port)) format args)))
  1321. diff -c slib/strcase.scm nlib/strcase.scm
  1322. *** slib/strcase.scm    Wed Nov 18 14:15:18 1992
  1323. --- nlib/strcase.scm    Tue Feb  9 00:22:03 1993
  1324. ***************
  1325. *** 8,27 ****
  1326.   ;string-upcase!, string-downcase!, string-capitalize!
  1327.   ; are destructive versions.
  1328.   
  1329. ! (define (string-upcase! str)
  1330.     (do ((i (- (string-length str) 1) (- i 1)))
  1331.         ((< i 0) str)
  1332.       (string-set! str i (char-upcase (string-ref str i)))))
  1333.   
  1334. ! (define (string-upcase str)
  1335.     (string-upcase! (string-copy str)))
  1336.     
  1337. ! (define (string-downcase! str)
  1338.     (do ((i (- (string-length str) 1) (- i 1)))
  1339.         ((< i 0) str)
  1340.       (string-set! str i (char-downcase (string-ref str i)))))
  1341.   
  1342. ! (define (string-downcase str)
  1343.     (string-downcase! (string-copy str)))
  1344.   
  1345.   (define (string-capitalize! str)    ; "hello" -> "Hello"
  1346. --- 8,30 ----
  1347.   ;string-upcase!, string-downcase!, string-capitalize!
  1348.   ; are destructive versions.
  1349.   
  1350. ! ;;; Declarations for CScheme
  1351. ! (declare (usual-integrations))
  1352. ! (define-integrable (string-upcase! str)
  1353.     (do ((i (- (string-length str) 1) (- i 1)))
  1354.         ((< i 0) str)
  1355.       (string-set! str i (char-upcase (string-ref str i)))))
  1356.   
  1357. ! (define-integrable (string-upcase str)
  1358.     (string-upcase! (string-copy str)))
  1359.     
  1360. ! (define-integrable (string-downcase! str)
  1361.     (do ((i (- (string-length str) 1) (- i 1)))
  1362.         ((< i 0) str)
  1363.       (string-set! str i (char-downcase (string-ref str i)))))
  1364.   
  1365. ! (define-integrable (string-downcase str)
  1366.     (string-downcase! (string-copy str)))
  1367.   
  1368.   (define (string-capitalize! str)    ; "hello" -> "Hello"
  1369. ***************
  1370. *** 38,42 ****
  1371.             (string-set! str i (char-upcase c))))
  1372.           (set! non-first-alpha #f))))))
  1373.   
  1374. ! (define (string-capitalize str)
  1375.     (string-capitalize! (string-copy str)))
  1376. --- 41,45 ----
  1377.             (string-set! str i (char-upcase c))))
  1378.           (set! non-first-alpha #f))))))
  1379.   
  1380. ! (define-integrable (string-capitalize str)
  1381.     (string-capitalize! (string-copy str)))
  1382. diff -c slib/synchk.scm nlib/synchk.scm
  1383. *** slib/synchk.scm    Mon Jan 27 09:28:48 1992
  1384. --- nlib/synchk.scm    Tue Feb  9 00:22:03 1993
  1385. ***************
  1386. *** 35,45 ****
  1387.   ;;; written by Alan Bawden
  1388.   ;;; modified by Chris Hanson
  1389.   
  1390. ! (define (syntax-check pattern form)
  1391.     (if (not (syntax-match? (cdr pattern) (cdr form)))
  1392.         (syntax-error "ill-formed special form" form)))
  1393.   
  1394. ! (define (ill-formed-syntax form)
  1395.     (syntax-error "ill-formed special form" form))
  1396.   
  1397.   (define (syntax-match? pattern object)
  1398. --- 35,48 ----
  1399.   ;;; written by Alan Bawden
  1400.   ;;; modified by Chris Hanson
  1401.   
  1402. ! ;;; Declarations for CScheme
  1403. ! (declare (usual-integrations))
  1404. ! (define-integrable (syntax-check pattern form)
  1405.     (if (not (syntax-match? (cdr pattern) (cdr form)))
  1406.         (syntax-error "ill-formed special form" form)))
  1407.   
  1408. ! (define-integrable (ill-formed-syntax form)
  1409.     (syntax-error "ill-formed special form" form))
  1410.   
  1411.   (define (syntax-match? pattern object)
  1412.